// 罗马数字转整数
#include <stdio.h>
#include <string.h>

int main()
{
    int romanToInt(char *s)
    {
        int a[256] = {0};
        int i = strlen(s) - 1;
        int sum = 0, max = 73;
        a['I'] = 1;
        a['V'] = 5;
        a['X'] = 10;
        a['L'] = 50;
        a['C'] = 100;
        a['D'] = 500;
        a['M'] = 1000;
        while (i >= 0)
        {
            if (a[s[i]] >= a[max])
            {
                sum += a[s[i]];
                max = s[i];
            }
            else
            {
                sum -= a[s[i]];
            }
            i--;
        }
        return sum;
    }
}
